import * as actionTypes from "./constants";

const initialState = {
  counter: 1,
  banners: [],
  recommends: [],
};

function reducer(state = initialState, action) {
  const { payload } = action;
  switch (action.type) {
    case actionTypes.ADD:
      return { ...state, counter: state.counter + payload };
    case actionTypes.MINUS:
      return { ...state, counter: state.counter - payload };
    case actionTypes.CHANGE_BANNERS:
      return { ...state, banners: payload };
    case actionTypes.CHANGE_RECOMMENDS:
      return { ...state, recommends: payload };
    default:
      return state;
  }
}

export default reducer;
